using Cache.Redis;
using Common;
using Model.Table;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

namespace Service.Table
{
    public class TableCommonProperty : TableBase
    {
        private const string Tablename = "Table_CommonProperty";

        public const string adventure_time_str = "adventure_time";
        public static int adventure_time;
        public const string game_hour_convert_second_str = "game_hour_convert_second";
        public static int game_hour_convert_second;
        public const string food_convert_gold_str = "food_convert_gold";
        public static int food_convert_gold;
        public const string fish_convert_gold_str = "food_convert_gold";
        public static int fish_convert_gold;
        public const string employee_spend_food_day_str = "employee_spend_food_day";
        public static int employee_spend_food_day;
        public const string fishing_time_str = "fishing_time";
        public static int fishing_time;
        public const string trade_time_str = "trade_time";
        public static int trade_time;
        public const string seamapscale_str = "seamapscale";
        public static float seamapscale;
        public const string init_ship_str = "init_ship";
        public static List<Tuple<int, int>> init_ship;
        public const string init_shiptrain_str = "init_shiptrain";
        public static int init_shiptrain;
        public const string init_sea_point_str = "init_sea_point";
        public static List<int> init_sea_point;
        public const string init_sea_connect_str = "init_sea_connect";
        public static List<int> init_sea_connect;
        public const string init_sea_mask_str = "init_sea_mask";
        public static List<int> init_sea_mask;
        public const string init_captain_str = "init_captain";
        public static List<int> init_captain;
        public const string init_gold_str = "init_gold";
        public static int init_gold;
        public const string init_food_str = "init_food";
        public static int init_food;
        public const string init_seaman_str = "init_seaman";
        public static int init_seaman;
        public const string init_workman_str = "init_workman";
        public static int init_workman;
        public const string init_diamond_str = "init_diamond";
        public static int init_diamond;
        public const string init_commodity_str = "init_commodity";
        public static List<int[]> init_commodity = new List<int[]>();
        public const string init_level_str = "init_level";
        public static int init_level;
        public const string windy_interval_str = "windy_refresh";
        public static int windy_interval;
        public const string windy_speedup_rate_str = "windy_speedup_rate";
        public static float windy_speedup_rate;
        public const string home_sea_mask_id_str = "home_sea_mask_id";
        public static int home_sea_mask_id;
        public const string home_sea_point_id_str = "home_sea_point_id";
        public static int home_sea_point_id;
        public const string fix_time_str = "fix_time";
        public static int fix_time;
        public const string fix_gold_str = "fix_gold";
        public static int fix_gold;
        public const string sea_event_refresh_str = "sea_event_refresh";
        public static int sea_event_refresh;
        public const string sea_price_refresh_str = "sea_price_refresh";
        public static int sea_price_refresh;
        public const string city_price_refresh_str = "city_price_refresh";
        public static int city_price_refresh;
        public const string durable_spend_str = "durable_spend";
        public static int durable_spend;
        public const string nofood_deadspeed_str = "nofood_deadspeed";
        public static int nofood_deadspeed;

        public override string GetTableName()
        {
            return Tablename;
        }

        public override void ParseToObject(Dictionary<string, object> _dic)
        {
            string property_name = _dic["property_name"].ToString();
            string property_value = _dic["property_value"].ToString();
            if (property_name == adventure_time_str)
            {
                adventure_time = int.Parse(property_value);
            }
            else if (property_name == game_hour_convert_second_str)
            {
                game_hour_convert_second = int.Parse(property_value);
            }
            else if (property_name == food_convert_gold_str)
            {
                food_convert_gold = int.Parse(property_value);
            }
            else if (property_name == fish_convert_gold_str)
            {
                fish_convert_gold = int.Parse(property_value);
            }
            else if (property_name == employee_spend_food_day_str)
            {
                employee_spend_food_day = int.Parse(property_value);
            }
            else if (property_name == fishing_time_str)
            {
                fishing_time = int.Parse(property_value);
            }
            else if (property_name == trade_time_str)
            {
                trade_time = int.Parse(property_value);
            }
            else if (property_name == seamapscale_str)
            {
                seamapscale = float.Parse(property_value);
            }
            else if (property_name == init_ship_str)
            {
                init_ship = new List<Tuple<int, int>>();
                //init_ship = property_value.Split(',').Select<string, int>(x => Convert.ToInt32(x)).ToList();
                var ship_list = property_value.Split('|').ToList();
                if (ship_list != null && ship_list.Any())
                {
                    for (int i = 0; i < ship_list.Count; i = i + 2)
                    {
                        init_ship.Add(new Tuple<int, int>(int.Parse(ship_list[i]), int.Parse(ship_list[i + 1])));
                    }
                }
            }
            else if (property_name == init_shiptrain_str)
            {
                init_shiptrain = int.Parse(property_value);
            }
            else if (property_name == init_sea_point_str)
            {
                init_sea_point = property_value.Split('|').Select<string, int>(x => Convert.ToInt32(x)).ToList();
            }
            else if (property_name == init_sea_connect_str)
            {
                init_sea_connect = property_value.Split('|').Select<string, int>(x => Convert.ToInt32(x)).ToList();
            }
            else if (property_name == init_sea_mask_str)
            {
                init_sea_mask = property_value.Split('|').Select<string, int>(x => Convert.ToInt32(x)).ToList();
            }
            else if (property_name == init_captain_str)
            {
                init_captain = property_value.Split('|').Select<string, int>(x => Convert.ToInt32(x)).ToList();
            }
            else if (property_name == init_gold_str)
            {
                init_gold = int.Parse(property_value);
            }
            else if (property_name == init_food_str)
            {
                init_food = int.Parse(property_value);
            }
            else if (property_name == init_seaman_str)
            {
                init_seaman = int.Parse(property_value);
            }
            else if (property_name == init_workman_str)
            {
                init_workman = int.Parse(property_value);
            }
            else if (property_name == init_diamond_str)
            {
                init_diamond = int.Parse(property_value);
            }
            else if (property_name == init_commodity_str)
            {
                init_commodity = new List<int[]>();
                string[] init_commodity_str_arr = property_value.Split('|');
                for (int i = 0; i < init_commodity_str_arr.Length; i++)
                {
                    string tmp_commodity = init_commodity_str_arr[i];
                    if (string.IsNullOrEmpty(tmp_commodity))
                    {
                        continue;
                    }
                    string[] tmp_commodity_arr = tmp_commodity.Split(';');
                    int[] commodity = new int[2];
                    commodity[0] = int.Parse(tmp_commodity_arr[0]);
                    commodity[1] = int.Parse(tmp_commodity_arr[1]);
                    init_commodity.Add(commodity);
                }
            }
            else if (property_name == init_level_str)
            {
                init_level = int.Parse(property_value);
            }
            else if (property_name == windy_interval_str)
            {
                windy_interval = int.Parse(property_value);
            }
            else if (property_name == windy_speedup_rate_str)
            {
                windy_speedup_rate = float.Parse(property_value);
            }
            else if (property_name == home_sea_mask_id_str)
            {
                home_sea_mask_id = int.Parse(property_value);
            }
            else if (property_name == home_sea_point_id_str)
            {
                home_sea_point_id = int.Parse(property_value);
            }
            else if (property_name == fix_time_str)
            {
                fix_time = int.Parse(property_value);
            }
            else if (property_name == fix_gold_str)
            {
                fix_gold = int.Parse(property_value);
            }
            else if (property_name == sea_event_refresh_str)
            {
                sea_event_refresh = int.Parse(property_value);
            }
            else if (property_name == sea_price_refresh_str)
            {
                sea_price_refresh = int.Parse(property_value);
            }
            else if (property_name == city_price_refresh_str)
            {
                city_price_refresh = int.Parse(property_value);
            }
            else if (property_name == durable_spend_str)
            {
                durable_spend = int.Parse(property_value);
            }
            else if (property_name == nofood_deadspeed_str)
            {
                nofood_deadspeed = int.Parse(property_value);
            }

        }


    }

}